package com.microboot.service.impl;

import com.microboot.annotation.AutoPublishWS;
import com.microboot.entity.product.dto.ProductReqsVO;
import com.microboot.entity.product.dto.ProductRespVO;
import com.microboot.service.user.dao.IProductService;
import jakarta.jws.WebParam;
import jakarta.jws.WebService;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;

@AutoPublishWS(publishPath = "AutoProductService")
@WebService(serviceName = "ProductService", //接口名称
        targetNamespace = "http://dto.product.entity.microboot.com", //接口命名空间
        endpointInterface = "com.microboot.service.user.dao.IProductService") //端点接口(endpointInterface中指定的必须是接口包路径+接口名称)
@Service //自动进行bean注册
public class ProductServiceImpl implements IProductService {

    @Override
    public ProductRespVO getProductInfo(@WebParam() ProductReqsVO productReqsVO) {
        //模拟随机数 1 到 500（不包括 500）的随机整数
        double price = Math.floor(Math.random() * (500 - 1) + 1);

        ProductRespVO respVO = new ProductRespVO();
        respVO.setProductId(productReqsVO.getProductId());
        respVO.setProductName(productReqsVO.getProductName());
        respVO.setProductTitle("产品标题:"+productReqsVO.getProductName());
        respVO.setProductPrice(new BigDecimal(price));
        respVO.setProductDetail("产品详情:"+productReqsVO.getProductName());
        return respVO;
    }
}
